package com.regex.web.controller.appoint;

import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.regex.web.base.BaseController;
import com.regex.web.service.fj.IClFjspInfoService;
import com.regex.web.service.kf.IClCjrsqjdkfzxfwService;
import com.regex.web.service.kf.IClKfSrkfjzargewService;
import com.regex.web.service.ty.IClTyCjrsqjjayfwService;
import com.regex.web.vo.ResultVO;


@RestController
@CrossOrigin
public class FjInfo extends BaseController{
	
	
	@Autowired
	private IClFjspInfoService IClFjspInfoService;
	
	@Autowired
	private IClKfSrkfjzargewService IClKfSrkfjzargewService;
	

	@Autowired
	private IClTyCjrsqjjayfwService IClTyCjrsqjjayfwService;
	
	/*各年度辅具适配总数*/
	@RequestMapping("getndspzs")
	@ResponseBody
	public ResultVO<List<Map>>  getndspzs(){
		List<Map> map=IClFjspInfoService.getndspzs();
		return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
		
	}
	/*辅具适配人按残疾等级统计*/
	@RequestMapping("getfjspdj")
	@ResponseBody
	public ResultVO<List<Map>>  getfjspdj(){
		List<Map> map=IClFjspInfoService.getfjspdj();
		return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
		
	}
	/*辅具适配类型统计 */
	@RequestMapping("getfjsplx")
	@ResponseBody
	public ResultVO<List<Map>>  getfjsplx(){
		List<Map> map=IClFjspInfoService.getfjsplx();
		return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
		
	}
	/*辅具适配人按年龄统计*/
	@RequestMapping("getfjspnl")
	@ResponseBody
	public ResultVO<List<Map>>  getfjspnl(){
		List<Map> map=IClFjspInfoService.getfjspnl();
		 Calendar cal = Calendar.getInstance();
	        int year = cal.get(Calendar.YEAR);
	        int a=0,b=0,c=0,d=0,e=0,f=0,g=0;
		for (Map map2 : map) {
			String nf=map2.get("ChuShengNianYue").toString().substring(0,4);
		 int nl=year -	Integer.parseInt(nf);
		 if(0 < nl && nl <=16){
			 map2.remove("ChuShengNianYue");
			 a=a+1;
		 }
		 if(16 < nl && nl <=30){
			 map2.remove("ChuShengNianYue");
			b=b+1;
		 }
		 if(30 < nl && nl <=45){
			 map2.remove("ChuShengNianYue");
			c=c+1;
		 }
		 if(45 < nl && nl <=60){
			 map2.remove("ChuShengNianYue");
			 d=d+1;
		 }
		 if(60 < nl && nl <=75){
			 map2.remove("ChuShengNianYue");
			e=e+1;
		 }
		 if(75 < nl && nl <=90){
			 map2.remove("ChuShengNianYue");
			f=f+1;
		 }
		 if(90 < nl ){
			 map2.remove("ChuShengNianYue");
			g=g+1;
		 }
	
		}
		map.clear();
		Map<String, Object> maps=new HashMap();
		 maps.put("name", "0-16");
		 maps.put("value", a);
		 map.add(maps);
		 Map<String, Object> map2=new HashMap();
		 map2.put("name", "16-30");
		 map2.put("value", b);
		 map.add(map2);
		 Map<String, Object> map3=new HashMap();
		 map3.put("name", "30-45");
		 map3.put("value", c);
		 map.add(map3);
		 Map<String, Object> map4=new HashMap();
		 map4.put("name", "45-60");
		 map4.put("value", d);
		 map.add(map4);
		 Map<String, Object> map5=new HashMap();
		 map5.put("name", "60-75");
		 map5.put("value", e);
		 map.add(map5);
		 Map<String, Object> map6=new HashMap();
		 map6.put("name", "75-90");
		 map6.put("value", f);
		 map.add(map6);
		 Map<String, Object> map7=new HashMap();
		 map7.put("name", "90以上");
		 map7.put("value", g);
		map.add(map7);
		return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
		
	}
	/*辅具区域数量*/
	@RequestMapping("getfjqysl")
	@ResponseBody
	public ResultVO<List<Map>>  getfjqysl(){
		List<Map> map=IClFjspInfoService.getfjqysl();
		return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
		
	}
	
	/*康复服务详情Top*/
	@RequestMapping("getfjspfw")
	@ResponseBody
	public ResultVO<List<Map>>  getfjspfw(){
		List<Map> map=IClFjspInfoService.getfjspfw();
		return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
		
	}
	
	/**
	 * 儿童康复救助
	 * @return
	 */
	
	@RequestMapping("getErjzfwbt")
	@ResponseBody
	public ResultVO<List<Map>>  getErjzfwbt(){
		List<Map> map=IClKfSrkfjzargewService.getErjzfwbt();
		return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
		
	}
	@RequestMapping("getkfjgqysl")
	@ResponseBody
	public ResultVO<List<Map>>  getkfjgqysl(){
		List<Map> map=IClKfSrkfjzargewService.getkfjgqysl();
		return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
		
	}
	/*
	 * 住房补助按区域划分
	 */
	@RequestMapping("getQybzZfbzqy")
	@ResponseBody
	public ResultVO<List<Map>>  getQybzZfbzqy(){
		List<Map> map=IClKfSrkfjzargewService.getQybzZfbzqy();
		return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
		
	}
	/*
	 * 住房补助按文化程度
	 */
	@RequestMapping("getQybzZfbzwhcd")
	@ResponseBody
	public ResultVO<List<Map>>  getQybzZfbzwhcd(){
		List<Map> map=IClKfSrkfjzargewService.getQybzZfbzwhcd();
		return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
		
	}
	/*
	 * 住房补助按中毒残疾
	 */
	@RequestMapping("getQybzZfbzdcj")
	@ResponseBody
	public ResultVO<List<Map>>  getQybzZfbzdcj(){
		List<Map> map=IClKfSrkfjzargewService.getQybzZfbzdcj();
		return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
		
	}

	/*
	 * 住房补助按残疾等级
	 */
	@RequestMapping("getQybzZfbzcjdj")
	@ResponseBody
	public ResultVO<List<Map>>  getQybzZfbzcjdj(){
		List<Map> map=IClKfSrkfjzargewService.getQybzZfbzcjdj();
		return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
		
	}
	
	/*
	 * 住房补助按残疾类别
	 */
	@RequestMapping("getQybzZfbzcjlb")
	@ResponseBody
	public ResultVO<List<Map>>  getQybzZfbzcjlb(){
		List<Map> map=IClKfSrkfjzargewService.getQybzZfbzcjlb();
		return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
		
	}
	/**
	 * 托养  
	 * @return
	 */
	@RequestMapping("getTyCjlb")
	@ResponseBody
	public ResultVO<List<Map>>  getTyCjlb(){
		List<Map> map=IClTyCjrsqjjayfwService.getTyCjlb();
		return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
		
	}
	@RequestMapping("getTyCjdj")
	@ResponseBody
	public ResultVO<List<Map>>  getTyCjdj(){
		List<Map> map=IClTyCjrsqjjayfwService.getTyCjdj();
		return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
		
	}
	@RequestMapping("getTyBtlx")
	@ResponseBody
	public ResultVO<List<Map>>  getTyBtlx(){
		List<Map> map=IClTyCjrsqjjayfwService.getTyBtlx();
		return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
		
	}

}
